﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GolfScoringApplication
{
    public partial class frmPhone : Form
    {
        private frmGolfer _frmParentGolfer;
        private frmGolfCourse _frmParentCourse;

        public frmPhone()
        {
            InitializeComponent();
        }

        public void LoadFormVariables(frmGolfer objParent)
        {
            _frmParentGolfer = objParent;
        }

        public void LoadFormVariables(frmGolfCourse objGolfCourse)
        {
            _frmParentCourse = objGolfCourse;
        }

        private void frmPhone_Load(object sender, EventArgs e)
        {
            LoadPhoneTypes();
        }

        private void LoadPhoneTypes()
        {
            
            cboPhoneType.Items.Clear();
            cboPhoneType.Items.Add(PhoneType.Cell.ToString());
            cboPhoneType.Items.Add(PhoneType.Work.ToString());
            cboPhoneType.Items.Add(PhoneType.Home.ToString());
            cboPhoneType.Items.Add(PhoneType.Other.ToString());
            cboPhoneType.SelectedIndex = 0;
        }

        private void cmdAdd_Click(object sender, EventArgs e)
        {
            PhoneType objType;
            switch (cboPhoneType.SelectedItem.ToString())
            {
                case "Cell":
                    {
                        objType = PhoneType.Cell;
                        break;
                    }
                case "Work":
                    {
                        objType = PhoneType.Work;
                        break;
                    }
                case "Home":
                    {
                        objType = PhoneType.Home;
                        break;
                    }
                case "Other":
                    {
                        objType = PhoneType.Other;
                        break;
                    }
                default:
                    {
                        objType = PhoneType.Cell;
                        break;
                    }

            }

            PhoneNumber objNewNumber = new PhoneNumber(objType,txtPhoneNum.Text);
            if (_frmParentCourse != null)
            {

            }
            if (_frmParentGolfer != null)
            {
                _frmParentGolfer.AddPhone(objNewNumber);
            }
            this.Close();
        }



    }
}
